.row
  .col-lg-12
    = form_for @project, url: project_settings_ci_cd_path(@project, anchor: 'autodevops-settings') do |f|
      = form_errors(@project)
      %fieldset.builds-feature.js-auto-devops-settings
        .form-group
          - message = auto_devops_warning_message(@project)
          - if message
            %p.auto-devops-warning-message.settings-message.text-center
              = message.html_safe
          = f.fields_for :auto_devops_attributes, @auto_devops do |form|
            .card.auto-devops-card
              .card-body
                .form-check
                  = form.check_box :enabled, class: 'form-check-input js-toggle-extra-settings', checked: @project.auto_devops_enabled?
                  = form.label :enabled, class: 'form-check-label' do
                    %strong= s_('CICD|Default to Auto DevOps pipeline')
                    - if @project.has_auto_devops_implicitly_enabled?
                      %span.badge.badge-info.js-instance-default-badge= s_('CICD|instance enabled')
                  .form-text.text-muted
                    = s_('CICD|The Auto DevOps pipeline will run if no alternative CI configuration file is found.')
                    = link_to _('More information'), help_page_path('topics/autodevops/index.md'), target: '_blank'
              .card-footer.js-extra-settings{ class: @project.auto_devops_enabled? || 'hidden' }
                = form.label :domain do
                  %strong= _('Domain')
                = form.text_field :domain, class: 'form-control', placeholder: 'domain.com'
                .form-text.text-muted
                  = s_('CICD|You need to specify a domain if you want to use Auto Review Apps and Auto Deploy stages.')
                  - if cluster_ingress_ip = cluster_ingress_ip(@project)
                    = s_('%{nip_domain} can be used as an alternative to a custom domain.').html_safe % { nip_domain: "<code>#{cluster_ingress_ip}.nip.io</code>".html_safe }
                  = link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'auto-devops-base-domain'), target: '_blank'

                %label.prepend-top-10
                  %strong= s_('CICD|Deployment strategy')
                %p.settings-message.text-center
                  = s_('CICD|Deployment strategy needs a domain name to work correctly.')
                .form-check
                  = form.radio_button :deploy_strategy, 'continuous', class: 'form-check-input'
                  = form.label :deploy_strategy_continuous, class: 'form-check-label' do
                    = s_('CICD|Continuous deployment to production')
                    = link_to icon('question-circle'), help_page_path('topics/autodevops/index.md', anchor: 'auto-deploy'), target: '_blank'
                .form-check
                  = form.radio_button :deploy_strategy, 'manual', class: 'form-check-input'
                  = form.label :deploy_strategy_manual, class: 'form-check-label' do
                    = s_('CICD|Automatic deployment to staging, manual deployment to production')
                    = link_to icon('question-circle'), help_page_path('ci/environments.md', anchor: 'manually-deploying-to-environments'), target: '_blank'

          = f.submit _('Save changes'), class: "btn btn-success prepend-top-15"
